<template>
  <div>
    <!--面包屑导航区-->
    <el-breadcrumb class="navigation">
      <el-breadcrumb-item :to="{ path: '/loginlog' }">系统管理</el-breadcrumb-item>
      <el-breadcrumb-item>操作日志</el-breadcrumb-item>
    </el-breadcrumb>
  <!-- 主体区域 -->
    <el-card class="notice">
        <h4>&nbsp;&nbsp;操作日志</h4>
      <!--搜索区域-->
      <el-row :gutter="20">
        <el-col :span="7">
          <el-input placeholder="请输入用户名称" v-model="queryInfo.oper_name">
            <el-button slot="append"
              icon="el-icon-search"
              @click="getOperationalLog"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <!--文件数据区域-->
      <el-table :data="OperationalLog"
        border
        stripe>
        <el-table-column label="#" type="index"></el-table-column>
        <el-table-column label="操作人" prop="operName"></el-table-column>
        <el-table-column label="模块标题" prop="modTitle"></el-table-column>
        <el-table-column label="请求方式" prop="requestMethod"></el-table-column>
        <el-table-column label="操作状态" prop="operStatus">
           <template slot-scope="scope">
            <el-tag  type="success" v-if="scope.row.operStatus === 1" >
             成功
            </el-tag>
            <el-tag type="danger" v-if="scope.row.operStatus === 0">
             失败
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作时间" prop="operTime"></el-table-column>
      </el-table>
      <!--分页区域-->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pageNum"
        :page-sizes="[1, 2, 5, 10]"
        :page-size="queryInfo.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
export default {
  data () {
    return {
      queryInfo: {
        // 当前页码
        pageNum: 1,
        pageSize: 10,
        oper_name: ''
      },
      total: 0,
      OperationalLog: []
    }
  },
  created () {
    this.getOperationalLog()
  },
  methods: {
    getOperationalLog () {
      this.$axios.get('admin/pogLog', {
        params: this.queryInfo
      }).then(res => {
        const info = res.data
        if (info.code !== 200) {
          console.log(info)
          this.$message({
            message: '获取文件数据失败',
            type: 'error',
            offset: 70
          })
        }
        this.OperationalLog = info.data.list
        this.total = info.data.total
      }).catch(err => {
        console.log(err)
      })
    },
    // 监听pagesize改变的事件
    handleSizeChange (newSize) {
      this.queryInfo.pageSize = newSize
      this.getOperationalLog()
    },
    // 监听页码值改变的事件
    handleCurrentChange (newPage) {
      this.queryInfo.pageNum = newPage
      this.getOperationalLog()
    }
  }
}
</script>
<style  scoped>
.navigation {
  padding: 10px;
}

.notice {
  margin-bottom: 40px;
  border-radius: 15px;
  box-shadow: 15px 15px 10px -12px #4c61a0;
}

h4 {
  padding-bottom: 8px;
  margin-bottom: 20px;
  border-bottom: 2px solid #4c61a0;
}

/* 搜索框 */
.el-table {
  margin-top: 15px;
}

/* 页码 */
.el-pagination {
  margin-top: 15px;
}
</style>
